extends CenterContainer


var data



func set_data(data):
	self.data = data
	
	$PanelContainer/VBoxContainer/Label.text = "【%s】%s" % [data["id"], data["name"]]
	var map_view = MainTool.getUILayer().get_ui("MapView")
	$PanelContainer/VBoxContainer/select.visible = map_view.select_entity_mode



func _on_delete_button_up():
	MainTool.confirm("你是否确认删除该传送门", self, "_on_del_ok", null, data)


func _on_del_ok(data):
	DataSource.delete_data_by_id(DataSource.map_door, data["id"])
	
	var map_view = MainTool.getUILayer().get_ui("MapView")
	map_view.entity_update()


func _on_select_button_up():
	var map_view = MainTool.getUILayer().get_ui("MapView")
	map_view.emit_select_signal(2, data)
	
	MainTool.getUILayer().pop_ui()
	MainTool.getUILayer().pop_ui()


func _on_info_button_up():
	MainTool.getUILayer().pop_ui()
	var ui = MainTool.getUILayer().add_ui("res://tool/page/map/mapView/modal/MapDoorModal.tscn", 0, false)
	ui.set_edit_data(data)


func _on_cancel_button_up():
	MainTool.getUILayer().pop_ui()


func _on_transmit_button_up():
	var next_door = DataSource.get_data_by_one(DataSource.map_door, data["nextId"])
	
	if next_door:
		MainTool.getUILayer().pop_ui()
		
		var map_data = DataSource.get_data_by_one(DataSource.map_register, next_door["mapId"])
		
		var ui = MainTool.getUILayer().add_ui("res://tool/page/map/mapView/MapView.tscn", 0, false)
		ui.set_data(map_data)
		
		ui.select_grid(next_door["x"], next_door["y"])
